this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(e,t,n,i,o,r,a,s,l){"use strict";var c;function h(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function p(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?h(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):h(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var g=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,p({opened:true},e)));n.setEventNamespace("BX.Landing.UI.Form.FormSettingsForm");n.subscribeFromOptions(l.fetchEventsFromOptions(e));i.Dom.addClass(n.layout,"landing-ui-form-form-settings");n.onFieldChange=n.onFieldChange.bind(babelHelpers.assertThisInitialized(n));n.onSwitchChange=n.onSwitchChange.bind(babelHelpers.assertThisInitialized(n));n.cache=new i.Cache.MemoryCache;if(n.options.toggleable){n.onSwitchChange(n.options.opened);if(!n.options.toggleableType||n.options.toggleableType===t.ToggleableType.Switch){n.getSwitch().setValue(n.options.opened);i.Dom.prepend(n.getSwitch().getNode(),n.header)}if(n.options.toggleableType===t.ToggleableType.Link){i.Dom.clean(n.header);i.Dom.append(n.getLink().getLayout(),n.header)}}if(i.Type.isPlainObject(n.options.help)){i.Dom.append(n.getHelp(n.options.help),n.footer)}return n}babelHelpers.createClass(t,[{key:"getHelp",value:function e(t){return this.cache.remember("help",(function(){return i.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-form-help">\n\t\t\t\t\t<a href="','" target="_blank">',"</a>\n\t\t\t\t</div>\n\t\t\t"])),t.href,t.text)}))}},{key:"addField",value:function e(n){if(i.Type.isFunction(n.subscribe)){n.subscribe("onChange",this.onFieldChange.bind(this))}babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"addField",this).call(this,n)}},{key:"replaceField",value:function e(n,o){if(i.Type.isFunction(o.subscribe)){o.subscribe("onChange",this.onFieldChange.bind(this))}babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"replaceField",this).call(this,n,o)}},{key:"onFieldChange",value:function e(t){this.emit("onChange",t.getData())}},{key:"getSwitch",value:function e(){var t=this;return this.cache.remember("switch",(function(){var e=new r.SmallSwitch({value:t.options.opened});e.subscribe("onChange",(function(e){t.onSwitchChange(e.getTarget().getValue())}));return e}))}},{key:"getLink",value:function e(){var t=this;return this.cache.remember("link",(function(){return new s.Link({text:t.options.title,color:s.Link.Colors.Grey,onClick:function e(){t.onSwitchChange(i.Dom.style(t.body,"display")==="none")}})}))}},{key:"onSwitchChange",value:function e(t){if(!t){this.cache.set("isOpened",false);i.Dom.style(this.body,"display","none");i.Dom.style(this.layout,"margin-bottom","20px")}else{this.cache.set("isOpened",true);i.Dom.style(this.body,"display",null);i.Dom.style(this.layout,"margin-bottom",null)}this.emit("onChange")}},{key:"isOpened",value:function e(){return i.Text.toBoolean(this.cache.get("isOpened"))}},{key:"setOffsetTop",value:function e(t){i.Dom.style(this.getLayout(),"margin-top","".concat(t,"px"))}},{key:"clear",value:function e(){this.fields.forEach((function(e){if(i.Type.isFunction(e.getLayout)){i.Dom.remove(e.getLayout())}else{i.Dom.remove(e.layout)}e.unsubscribeAll("onChange")}));this.fields.clear()}}]);return t}(o.BaseForm);babelHelpers.defineProperty(g,"ToggleableType",{Link:"link",Switch:"switch"});e.FormSettingsForm=g})(this.BX.Landing.UI.Form=this.BX.Landing.UI.Form||{},BX,BX,BX,BX.Landing.UI.Form,BX.Landing.UI.Field,BX.Event,BX.Landing.UI.Component,BX.Landing.UI.Component);
//# sourceMappingURL=formsettingsform.bundle.map.js